package org.infodavid.common.model;

import java.util.ArrayList;
import java.util.List;

import org.infodavid.common.IBuilder;
import org.infodavid.common.ejb.ApplicationSettingsBean;

/**
 * The Class ApplicationSettingsTest.
 */
public class ApplicationSettingsTest extends AbstractBeanTest<IApplicationSettings> {

	/** The organization test. */
	private final OrganizationTest organizationTest = new OrganizationTest(this);

	/**
	 * Instantiates a new group test.
	 * @param mainTest the main test
	 */
	public ApplicationSettingsTest(final AbstractPersistenceTest mainTest) {
		super(mainTest);
	}

	/**
	 * Instantiates a new group test.
	 */
	public ApplicationSettingsTest() {
		super();
	}

	/**
	 * Populate.
	 * @param count the count
	 * @return the collection< test data>
	 * @throws Exception the exception
	 */
	@Override
	protected List<IApplicationSettings> doCreate(final int count) throws Exception {
		final IBuilder<IApplicationSettings> builder =
		    ModelFactory.getInstance().getBuilder(IApplicationSettings.class);
		final List<IApplicationSettings> items = new ArrayList<IApplicationSettings>(count);
		final IOrganization organization = organizationTest.populate(1).get(0);
		IApplicationSettings item;

		for (int i = 0; i < count; i++) {
			item = builder.create();

			item.setArchived(false);
			item.setProduct("item-" + System.nanoTime());
			item.setOrganization(organization);

			item.getProperties().addData("key1", "value1");
			item.getProperties().addData("key2", "value2");

			items.add(item);
		}

		return items;
	}

	/**
	 * See super class or interface. (non-Javadoc)
	 * @see org.infodavid.common.model.AbstractBeanTest#getEntityClass()
	 */
	@Override
	public Class<ApplicationSettingsBean> getEntityClass() {
		return ApplicationSettingsBean.class;
	}

	/**
	 * See super class or interface. (non-Javadoc)
	 * @see org.infodavid.common.model.AbstractBeanTest#getEntityName()
	 */
	@Override
	public String getEntityName() {
		return IApplicationSettings.class.getSimpleName();
	}
}
